home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Essentials / MacApp Documentation / MacApp.TECH$ Archives / 1988 / Oct⁄Nov 88 / Re-Default button woes⁄ < prev    next >
Encoding:
Text File  |  1991-03-06  |  3.6 KB  |  102 lines  |  [TEXT/GEOL]

  1. Item    2361268                         21-Oct-88        17:07
  2.  
  3. From:   CREMER.M                        Cremer, Mike
  4.  
  5. To:     D1430                           HewLett Packard, Dev, Steve Henry
  6.  
  7. cc:     MACAPP.TECH$                    MACAPP Tech
  8.         MACDTS                          Macintosh Developer Technical Supt.
  9.  
  10. Sub:    re Default Button Woes
  11.  
  12. Hal,
  13. You don't mention whether you are using modal or modeless dialogs--there is a
  14. difference in the way to handle each.  Modal dialogs could be done something
  15. like this:
  16.     { codefrag for modal dialog in MacApp 2.0 }
  17. VAR
  18.     aWindow : TWindow;
  19.     dismisser : IDType;
  20. BEGIN
  21.     aWindow := NewTemplateWindow(vMyDialog, NIL);
  22.     { set default information, if any }
  23.     dismisser := TDialogView(aWindow.FindSubView('DLOG')).PoseModally;
  24.     IF (dismisser = 'ok  ') THEN
  25.         { get information from fields/buttons }
  26.     aWindow.Close;
  27. END;
  28.  
  29. where { get information } could be checking the status of controls (i.e. radio
  30. buttons/check boxes) or reading text from EditText fields.  This could also be
  31. handled by overriding TDialogView.DismissDialog.
  32.  
  33. A resource setup for above codefrag could be something like:
  34.  
  35. /* rez code for standard ok/cancel modal dialog, MacApp 2.0 */
  36. resource 'view' (vMyDialog) {
  37.        {
  38.            root, 'WIND', { 50, 50 }, { 200, 300 },
  39.            sizeFixed, sizeFixed, shown, enabled,
  40.            Window {
  41.                "TWindow",
  42.             dBoxProc, noGoAwayBox, notResizable, modal,
  43.                ignoreFirstClick, freeOnClosing, disposeOnFree,
  44.                closesDocument, openWithDocument, dontAdaptToScreen,
  45.                dontStagger, forceOnScreen, centerHorizontally,
  46.                'DLOG',  /* !!! window target view is set to DLOG part of view
  47. */
  48.                "OK/Cancel Dialog"
  49.                };
  50.  
  51.         /*  The actual DialogView object */
  52.            'WIND', 'DLOG',  { 0, 0 }, { 200, 300 },
  53.            sizeFixed, sizeFixed, shown, enabled,
  54.            DialogView {
  55.                "TDialogView", /* or whatever */
  56.             'ok  ', /* specifies the OK and CANCEL default controls */
  57.                'cncl'  /* used by MacApp for Return and Command-. respectively
  58. */
  59.                };
  60.  
  61.            'DLOG', 'ok  ', { 160, 110 }, { 28, 80 },
  62.            sizeFixed, sizeFixed, shown, enabled,
  63.            Button {
  64.                "TButton",
  65.                adnRRect, {3, 3},   /* hilite the default control */
  66.             notSizeable, notDimmed,    notHilited,
  67.             dismisses,      /* says this control should call DismissDialog */
  68.                { 4, 4, 4, 4 }, systemFont,
  69.             "OK"
  70.             };
  71.  
  72.            'DLOG', 'cncl', { 164, 30 }, { 20, 80 },
  73.            sizeFixed, sizeFixed, shown, enabled,
  74.            Button {
  75.                "TButton",
  76.                noAdornment,    notSizeable,    notDimmed,  notHilited,
  77.             dismisses, noInset, systemFont,
  78.             "Cancel"
  79.             };
  80.  
  81. /* Plus whatever items are in the dialog itself.
  82.     Which could include other controls, handled
  83.     in the TDialogView.DoChoice method  */
  84.  
  85. Modal dialogs are a bit trickier.  A quick-n-dirty way is to override
  86. TDialogView.HandleCR so that it hilites the default button and calls your
  87. method (look at the code to see how MacApp does it).
  88.  
  89. The key factor here is to make sure the TWindow resource definition targets
  90. TDialogView by default, which alleviates all the tedious mucking about in
  91. fields.  Above, when the window is opened, it automagically targets 'DLOG'
  92. which gets the first shot at handling the event.  The DialogView resource
  93. should specify the equivalent of "OK" and "Cancel" default items.
  94.  
  95. Hope this helps.
  96.  
  97. $mike cremer
  98. Apple Computer, Inc.
  99.  
  100.  
  101.  
  102.